<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<link rel="stylesheet" type="text/css" href="detail.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		</header>
		<div class="mui-content">
			<div id="slider" class="mui-slider">
				<div class="mui-slider-group mui-slider-loop">
					<!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
					<div class="mui-slider-item mui-slider-item-duplicate">
						<a href="#">
							<img src="../images/shangpin.png">
						</a>
					</div>
					<!-- 第一张 -->
					<div class="mui-slider-item">
						<a href="#">
							<img src="../images/shangpin.png">
						</a>
					</div>
					<!-- 额外增加的一个节点(循环轮播：最后一个节点是第一张轮播) -->
					<div class="mui-slider-item mui-slider-item-duplicate">
						<a href="#">
							<img src="images/shangpin.png">
						</a>
					</div>
				</div>
				<div class="mui-slider-indicator">
					<div class="mui-number">
						<span>1</span> / 1
					</div>
				</div>
			</div>
			<div class="content">
				<h3></h3>
				<p class="price"></p>

			</div>
			<div class="line"></div>
			<div class="number-choose">
				<h4>选择数量</h4>
				<div class="mui-numbox" data-numbox-min='1' data-numbox-max='9'>
					<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
					<input class="mui-input-numbox" type="number" id="num" />
					<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
				</div>
				
			</div>
			<div class="line"></div>
			<p class="detail-title">
				<b></b> 商品详情
				<b></b>
			</p>
			<div class="content_info"></div>
			<!--<img src="../images/raw_1522181746.png" />-->
		</div>
		<nav class="mui-bar mui-bar-tab">
			<span>直接购买</span>
			<span>信用购买</span>
		</nav>
		<script src="../lib/mui.min.js"></script>
		<script type="text/javascript" src="../lib/jquery-1.11.0.js"></script>
		<script type="text/javascript" src="../lib/service.js"></script>
		<script type="text/javascript" src="product.js"></script>
		<script type="text/javascript">
			mui.init()
			var parms = {};
			var flag = flag;
			var data;
			var str;
			mui.plusReady(function() {
				str = plus.webview.currentWebview().parms;
				console.log(str)

				$('.mui-bar-tab span').bind('tap', function() {
//					openurl('../auth/address.html',JSON.stringify({id:1}));
					parms.type = $(this).index();
					if($(this).index() == 0) {
						if(data.data.address == null) {
							mui.toast("未填写收货地址，请进行填写")
							openurl('../auth/address.html',JSON.stringify({id:1}));
							return
						}
					} else {
						if(!flag) {
							mui.toast("请先进行资质审核")
							setTimeout(function() {
								plus.webview.currentWebview().close()
							}, 1000)
							return;
						}
					}
					parms.num = $('#num').val()
					console.log(JSON.stringify(parms))
					openurl('../buy/purchasing.html', JSON.stringify(parms))
				})
				init()
			})

			function init() {
				data = null;
				getServer('app/applyDetail', $.param({
					goodId: JSON.parse(str).id
				}), function(res) {
					console.log(JSON.stringify(res))
					//设置产品信息
					$('.content h3').html(res.data.goods.name);
					$('.price').html("¥ "+res.data.goods.price);
					$('.mui-slider-item a img').attr('src',serverUrl + 'upload/' +res.data.goods.img)
					$('.content_info').html(res.data.goods.info)
					//				console.log(res.data.code)
					data = res
					if(res.data.member.auditFlag == 3) {
						flag = true
					}
					if(res.data.address != null || res.data.member != null) {
						parms.data = res.data
						console.log(JSON.stringify(parms))
					} else {
						mui.toast("请登陆")
						openurl('../landing/login.html')
					}

				});
			}
		</script>
	</body>

</html>